//
//  StepperDemo.swift
//  SwiftUIDemo
//
//  Created by Tilt Wang on 2025/7/1.
//

import SwiftUI

struct StepperDemo: View {
    
    @State var stepperValue: Int = 10
    @State var widthIncrement: Int = 0
    
    var body: some View {
        VStack {
            Stepper("Stepper: \(stepperValue)", value: $stepperValue)
                .padding(50)
            
            RoundedRectangle(cornerRadius: 25.0)
                .frame(width: CGFloat(100 + widthIncrement), height: 100)
            
            Stepper("Stepper 2") {
                incrementWidth(10)
            } onDecrement: {
                incrementWidth(-10)
            }
            .padding(50)

        }
    }
    
    func incrementWidth(_ amount: Int) {
        withAnimation(.easeInOut) {
            widthIncrement += amount
        }
    }
    
}

#Preview {
    StepperDemo()
}
